﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HousingDistribution
{
    public partial class FormRptPara : Form
    {
        public FormRptPara()
        {
            InitializeComponent();
        }

        public void SetGetHousingDisRptParaDelegate(SetHousingDisRptParaDelegate func)
        {
            this.setHousingRtpParaFunc = func;
        }

        public void SetGetHousingStandRptDelegate(SetHousingStandRptDelegate func)
        {
            this.setHousingStandRptFunc = func;
        }

        SetHousingDisRptParaDelegate setHousingRtpParaFunc;
        SetHousingStandRptDelegate setHousingStandRptFunc;

        //rank 尽在 type为 PersonTypeEnum.ArmMan时有效
        public delegate void SetHousingDisRptParaDelegate(PersonTypeEnum type, ArmmanGradeEnum rank);
        //upToStand
        public delegate void SetHousingStandRptDelegate(bool upToStand);

        private void buttonRptHousingDis_Click(object sender, EventArgs e)
        {
            PersonTypeEnum type;
            ArmmanGradeEnum rank = ArmmanGradeEnum.Army;

            if (radioButtonArmy.Checked)
            {
                type = PersonTypeEnum.ArmMan;
                rank = ArmmanGradeEnum.Army; 
            }
            else if (radioButtonDivision.Checked)
            {
                type = PersonTypeEnum.ArmMan;
                rank = ArmmanGradeEnum.Division; 
            }
            else if (radioButtonRegiment.Checked)
            {
                type = PersonTypeEnum.ArmMan;
                rank = ArmmanGradeEnum.Regiment; 
            }
            else if (radioButtonBattalion.Checked)
            {
                type = PersonTypeEnum.ArmMan;
                rank = ArmmanGradeEnum.Battalion; 
            }
            else if (radioButtonStaff.Checked)
            {
                type = PersonTypeEnum.Staff;
            }
            else if (radioButtonWorker.Checked)
            {
                type = PersonTypeEnum.Worker;
            }
            else if (radioButtonNCO.Checked)
            {
                type = PersonTypeEnum.NCO;
            }
            else if (radioButtonBeforetimePerson.Checked)
            {
                type = PersonTypeEnum.ArmMan;
                rank = ArmmanGradeEnum.All;
            }
            else if (radioButtonBeforetimePerson.Checked)
            {
                type = PersonTypeEnum.ArmMan;
            }
            else
            {
                return;
            }
            this.Close();

            this.setHousingRtpParaFunc(type, rank);
        }

        private void buttonRtpHousingStandard_Click(object sender, EventArgs e)
        {
            bool upToStand = false;

            if (radioButtonUpToStandard.Checked)
            {
                upToStand = true;
            }
            else if (radioButtonNotUpToStandard.Checked)
            {
                upToStand = false;
            }
            else
                return;

            this.Close();

            this.setHousingStandRptFunc(upToStand);
        }
        
        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
